import { IUpdateInfo, IUpdatePassword, IUserInfoVo, IUserLogin } from './login.typings'
import { http } from '@/utils/http'

/**
 * 登录表单
 */
export interface ILoginForm {
  mobilePhone: number
  checkNumber: number
}
export interface ICheckNumberForm {
  phone: number
}
/**
 * 用户登录
 * @param loginForm 登录表单
 */
export const login = (loginForm: ILoginForm) => {
  return http.post<any>('/mobile/login/sms-login', {
    phone: loginForm.mobilePhone,
    code: loginForm.checkNumber,
  })
}
/**
 * 获取验证码
 */
export const getCheckNumber = (checkNumberForm: ICheckNumberForm) => {
  return http.get<any>('/mobile/login/get-sms-code', checkNumberForm)
}
/**
 * 获取用户信息
 */
export const getUserInfo = () => {
  return http.get<any>('/mobile/home/user')
}

/**
 * 退出登录
 */
export const logout = () => {
  return http.get<void>('/user/logout')
}

/**
 * 修改用户信息
 */
export const updateInfo = (data: IUpdateInfo) => {
  return http.post('/user/updateInfo', data)
}

/**
 * 修改用户密码
 */
export const updateUserPassword = (data: IUpdatePassword) => {
  return http.post('/user/updatePassword', data)
}
